package 作业;
import java.io.UnsupportedEncodingException ;

public class 作业1 {
    public static void main(String[] args) throws UnsupportedEncodingException {
        System.out.println("xk");

        String s = "静夜思 李白: 床前明月光，疑是地上霜。举头望明月，低头思故乡。";

        int index = s.indexOf("床");


        String title = s.substring(0, index);    //截取标题

        String content = s.substring(index);


        System.out.println("格式一：" + "\n" + title);


        String[] lines = content.split("[，。]");

        for (int i = 0; i < lines.length; i++) {

            System.out.println(lines[i]);

        }


        System.out.println();


        int index1 = s.indexOf("床");

        int index2 = s.indexOf("疑");

        int index3 = s.indexOf("举");

        int index4 = s.indexOf("低");


        String content1 = s.substring(index1, index2);

        String content2 = s.substring(index2, index3);

        String content3 = s.substring(index3, index4);

        String content4 = s.substring(index4);


        System.out.println("格式二：" + "\n" + title);


        char[] lines1 = content1.toCharArray();

        char[] lines2 = content2.toCharArray();

        char[] lines3 = content3.toCharArray();

        char[] lines4 = content4.toCharArray();

        for (int i = 0; i < lines1.length - 1; i++) {

            System.out.print(lines1[i]);

            System.out.print(lines2[i]);

            System.out.print(lines3[i]);

            System.out.println(lines4[i]);


        }

    }
}